package com.lanxiao.cloud.modules.oauth.application.assembler;

import com.lanxiao.cloud.common.core.dto.ResultModel;
import com.lanxiao.cloud.common.core.dto.UserBaseDto;
import com.lanxiao.cloud.common.fill.FillAppointment;
import com.lanxiao.cloud.common.fill.FillHandle;
import com.lanxiao.cloud.common.fill.FillHandleFactory;
import com.lanxiao.cloud.common.fill.FillType;
import com.lanxiao.cloud.modules.oauth.application.dto.LoginUserInfoDto;
import com.lanxiao.cloud.modules.oauth.application.dto.PermissionTreeDto;
import com.lanxiao.cloud.modules.oauth.application.dto.RegisterCmd;
import com.lanxiao.cloud.modules.oauth.application.dto.UserDetailsDto;
import com.lanxiao.cloud.modules.oauth.domain.model.UserAuth;
import com.lanxiao.cloud.modules.oauth.domain.model.UserDetails;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Component;

/**
 * @author ：qiaoliang
 * @date ：2021-09-14
 */
@Component
public class OauthAssembler {

  public ResultModel<UserDetailsDto> toUserDetailsDto(List<UserDetails> userDetails, int count) {
    return new ResultModel<>(OauthConverter.INSTANCE.toUserDetailsDto(userDetails), count);
  }

  public LoginUserInfoDto toLoginUserInfoDto(UserDetails userDetails) {
    return OauthConverter.INSTANCE.toLoginUserInfoDto(userDetails);
  }

  public UserAuth toUserAuth(RegisterCmd registerCmd) {
    return OauthConverter.INSTANCE.toUserAuth(registerCmd);
  }

  @Mapper
  public interface OauthConverter {

    OauthConverter INSTANCE = Mappers.getMapper(OauthConverter.class);

    UserAuth toUserAuth(RegisterCmd registerCmd);

    UserDetailsDto toUserDetailsDto(UserDetails userDetails);
    List<UserDetailsDto> toUserDetailsDto(List<UserDetails> userDetails);

    LoginUserInfoDto toLoginUserInfoDto(UserDetails userDetails);
  }

}
